-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(react): Add versioning for workspace libraries #19063
feat(react): Add versioning for workspace libraries #19063
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
I'm not sure this is the correct approach. When we run the build of a remote or host, the We do set requiredVersion: workspaceLib.packageJson?.version ?? false Then the user can define a range of versions of the library that the app is compatible with in their
If their workspace library does not have a package.json file, they can add one with just I tested this out locally, and it does work. If the This should also reduce the need of an additional property in the config. |
f3c2932
to
78f1c8d
Compare
e323d61
to
95e1e99
Compare
@@ -371,6 +373,80 @@ describe('MF Share Utils', () => { | |||
).not.toThrow(); | |||
}); | |||
}); | |||
|
|||
it('should using shared library version from root package.json if available', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a clean-up item later, but it'd be nice to use either a real fs, or mem-fs
here. Spying and mocking like this couples the test to the implementation too much. For example, if existsSync
and realTsPathMappings
are replaced with something else we'd have to update unit tests.
mem-fs
can be used like:
import 'nx/src/utils/testing/mock-fs';
import { vol } from 'memfs';
// ...
vol.fromJson({
'tsconfig.base.json': { ... },
// ...
}, '/');
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably a cleanup task. If we are changing over to use this it would make sense to update all the unit test inside share.spec.ts
65bcdf7
to
7fe6843
Compare
7fe6843
to
3f8600a
Compare
3f8600a
to
77f7f8f
Compare
77f7f8f
to
240d0a2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 🎉
in a follow up task we should add or change the e2e to build the shell, then change the version of the lib, then build the remote.
then we should read the main.js file of the shell to find the version the library is being registered with by MFP, and check it is at the earlier version, and then we should look for the same line in the remote’s remoteEntry.mjs and check its version matches the new version.
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
This PR grants users the ability to add versioning for their workspace libraries.
At build time inside
withModuleFederation
get each workspace library's version by:package.json
to get the version rangepackage.json
to get the fixed versionIf the need arises where you do not want this functionality (since it is the current default) you can override it by using the
shared
API inside of themodule-federation.config.js
.When your code is built you can check the build artifact's
remoteEntry.js
for yourhost
/remote
and you should see your workspace library registered with a version.